﻿var map_data = window.location.search.substring(1);
//decodeURIComponent()解码
var map_start = JSON.parse(decodeURIComponent(map_data.substring(map_data.indexOf('=')+1,map_data.indexOf('&'))))  ;
var map_end = JSON.parse(decodeURIComponent(map_data.substring(map_data.lastIndexOf('=')+1)));

LocalGeocoderFrist();

$(".buttons-row .tab-link-button").on('click',function () {

    var index;

    if ($(this).attr("data-index") == "drive-top") {
        ISS_MAP_SEARCHTYPE = 1;
        index = 0;
    } else if ($(this).attr("data-index") == "walk-top") {
        ISS_MAP_SEARCHTYPE = 2;
        index = 1;
    } else if ($(this).attr("data-index") == "bus-top") {
        ISS_MAP_SEARCHTYPE = 3;
        index = 2;
    }
    LocalGeocoder();
    $("#buttons-tabs").children().removeClass('active');
    $("#buttons-tabs").children().eq(index).addClass('active');
});

function LocalGeocoderFrist(){
    ISS_MAP_SEARCHTYPE = 1;
    LocalGeocoder();
}

// $("#tab-link-button").click(function () {
function LocalGeocoder(){
    //    var str = "开始点:";
    //    str += "lng" + ISS_MAP_SEARCH_START.Lng + "," + ISS_MAP_SEARCH_START.Lat;
    //    str += "结束点:";
    //    str += "lng" + ISS_MAP_SEARCH_END.Lng + "," + ISS_MAP_SEARCH_END.Lat;
    //    alert(str);

    //判断输入是否完整
    ISS_MAP_SEARCH_START.Lat = map_start.Lat;
    ISS_MAP_SEARCH_START.Lng = map_start.Lng;
    ISS_MAP_SEARCH_START.Name = map_start.Name;

    ISS_MAP_SEARCH_END.Lat = map_end.Lat;
    ISS_MAP_SEARCH_END.Lng = map_end.Lng;
    ISS_MAP_SEARCH_END.Name = map_end.Name;


    //隐藏pickmodal
    //    ISS_MAP.CloseModal();
    $("#pickbar")[0].style.height = "20px";
    $("#map-box")[0].style.height = "calc(100% - 20px)";
    //查询并展示结果
    if (ISS_MAP_SEARCHTYPE == 1) {
        //驾车
        ISS_Map_driving.SearchDrivingTab(0);
    } else if (ISS_MAP_SEARCHTYPE == 2) {
        //步行
        ISS_Map_walk.SearchWalkTab();
    } else if (ISS_MAP_SEARCHTYPE == 3) {
        //公交
        ISS_Map_bus.SearchBusTab(0);
    }
};


